package cn.xiaye.blog.servlet;

import java.util.List;

import cn.xiaye.blog.bean.Article;
import cn.xiaye.blog.bean.Context;
import cn.xiaye.blog.bean.Message;
import cn.xiaye.blog.bean.Sort;
import cn.xiaye.blog.dao.ArticleDao;
import cn.xiaye.blog.dao.MessageDao;
import cn.xiaye.blog.dao.SortDao;

@SuppressWarnings("serial")
public class ShowArticle extends FatherServlet {
	public String excute(Context context) {
		SortDao sortDao = new SortDao();
		List<Sort> sortList = sortDao.queryAll();
		
		ArticleDao articleDao = new ArticleDao();
		String str = context.getRequest().getParameter("article_id");
		Article article = articleDao.queryByArticleId(Integer.valueOf(str));
		
		MessageDao messageDao = new MessageDao();
		List<Message> messageList = messageDao.queryByArticleId(Integer.valueOf(str));
		
		context.getRequest().setAttribute("article", article);
		context.getRequest().setAttribute("SortList", sortList);
		context.getRequest().setAttribute("messageList", messageList);
		
		return "blog.jsp";
	}

}
